
CC := gcc
 
#load lib   -L load path of the lib ; -l load name of the lib
LDFLAGS := -lpthread -ldl -lm
 
#name the target project
TARGET := photos
CFLAGS := -Wall -O3 -g -Wno-deprecated-declarations

#delete info of "is deprecated"
CFLAGS += -Wno-deprecated-declarations

# Input error of warning
CFLAGS += -Werror

#gtk+-3.0
CFLAGS  += $(shell pkg-config --cflags gtk+-3.0)
LDFLAGS += $(shell pkg-config --libs gtk+-3.0)

#libopenjp2
CFLAGS  += $(shell pkg-config --cflags libopenjp2)
LDFLAGS += $(shell pkg-config --libs libopenjp2)

#libjpeg
CFLAGS  += $(shell pkg-config --cflags libjpeg)
LDFLAGS += $(shell pkg-config --libs libjpeg)

#poppler-glib
CFLAGS  += $(shell pkg-config --cflags poppler-glib)
LDFLAGS += $(shell pkg-config --libs poppler-glib)

CFLAGS  += -I./src \
			-I./src/bar/ \
			-I./src/cache/ \
			-I./src/collect \
			-I./src/file  \
			-I./src/format \
			-I./src/image \
			-I./src/layout \
			-I./src/menu \
			-I./src/ui \
			-I./src/utils \
			-I./src/view \
			-I./src/view_file

# get all files name is *.c to C_SRC
C_SRC = $(wildcard src/*.c)
C_SRC += $(wildcard src/bar/*.c)
C_SRC += $(wildcard src/cache/*.c)
C_SRC += $(wildcard src/collect/*.c)
C_SRC += $(wildcard src/file/*.c)
C_SRC += $(wildcard src/format/*.c)
C_SRC += $(wildcard src/image/*.c)
C_SRC += $(wildcard src/layout/*.c)
C_SRC += $(wildcard src/menu/*.c)
C_SRC += $(wildcard src/ui/*.c)
C_SRC += $(wildcard src/utils/*.c)
C_SRC += $(wildcard src/view/*.c)
C_SRC += $(wildcard src/view_file/*.c)
 
#replace *.c to *.o from variable SOUTCE_C, and get the name string to variable OBJECT_O
OBJECT_O = $(C_SRC:.c=.o)
 
#.c.o:
%.o: %.c
	$(CC) -c $(CFLAGS) $< -o $@  
 
$(TARGET): $(OBJECT_O)
	$(CC) ${CFLAGS}   $(OBJECT_O) $(LDFLAGS) -o $@

clean:
	@rm -rf $(TARGET) $(OBJECT_O)
 